package io.renren.modules.communityService.controller;

import java.util.Arrays;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.communityService.dto.DbNoticeDTO;
import io.renren.modules.communityService.vo.DbNoticeVO;
import io.renren.modules.communityService.service.DbNoticeService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 通知表
 *
 * @author chenweilong
 * @email 1433471850@qq.com
 * @date 2021-05-11 20:26:23
 */
@RestController
@RequestMapping("communityService/dbnotice")
@Api(value = "pc通知表",tags = "pc通知表")
public class DbNoticeController {
    @Autowired
    private DbNoticeService dbNoticeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation(value = "list",notes = "list")
    public R list(DbNoticeDTO dbNotice){
        PageUtils page = dbNoticeService.queryPage(dbNotice);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation(value = "info",notes = "info")
    public R info(@PathVariable("id") Integer id){
		DbNoticeVO dbNotice = dbNoticeService.getById(id);

        return R.ok().put("dbNotice", dbNotice);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation(value = "save",notes = "save")
    public R save(@RequestBody DbNoticeDTO dbNotice){
		dbNoticeService.save(dbNotice);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation(value = "update",notes = "update")
    public R update(@RequestBody DbNoticeDTO dbNotice){
		dbNoticeService.updateById(dbNotice);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ApiOperation(value = "delete",notes = "delete")
    public R delete(@RequestBody Integer[] ids){
		dbNoticeService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
